﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace LarDosIdosos
{
    public partial class Higiene : System.Web.UI.Page
    {
        private Business.Model.Funcionario funcionario;
        private const string Acesso = "acesso";
        private const string Editar = "editar";

        protected void Page_Load(object sender, EventArgs e)
        {
            CarregaFuncionario();
            if (!ValidaPermissao("acesso"))
            {
                Response.Redirect("~/Default.aspx");
            }
        }

        private void CarregaFuncionario()
        {
            if (Session["usuario"] != null)
            {
                funcionario = (Business.Model.Funcionario)Session["usuario"];
            }
        }

        //Note: Valida a permissão do funcionario
        private bool ValidaPermissao(string tipo)
        {
            if (funcionario != null)
            {
                switch (tipo)
                {
                    case Acesso:
                        if (funcionario.Cargo_Funcionario.CodigoCargo == 3)
                        {
                            return true;
                        }
                        break;
                    case Editar:
                        if (funcionario.Cargo_Funcionario.CodigoCargo == 2)
                        {
                            return true;
                        }
                        break;
                }
            }
            return false;
        }



        protected void gridView_DataBound(object sender, EventArgs e)
        {

        }

        protected void gridView_OnRowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                
            }
        }

        protected void gridView_OnRowCommand(object sender, GridViewCommandEventArgs e)
        {
            //if (e.CommandName == "visualizar")
            //{
            //    int index = Convert.ToInt32(e.CommandArgument);
            //    GridViewRow row = gridViewAlimentos.Rows[index];
            //    HiddenField hiddenField = (HiddenField)row.FindControl("hiddenFieldId");
            //    if (hiddenField != null) MontaPaginaComDetalhes(Convert.ToInt32(hiddenField.Value), false);

            //}
            //if (e.CommandName == "editar")
            //{
            //    int index = Convert.ToInt32(e.CommandArgument);
            //    GridViewRow row = gridViewAlimentos.Rows[index];
            //    HiddenField hiddenField = (HiddenField)row.FindControl("hiddenFieldId");
            //    if (hiddenField != null) MontaPaginaComDetalhes(Convert.ToInt32(hiddenField.Value), true);

            //}
            //if (e.CommandName == "excluir")
            //{
            //    int index = Convert.ToInt32(e.CommandArgument);
            //    GridViewRow row = gridViewAlimentos.Rows[index];
            //    HiddenField hiddenField = (HiddenField)row.FindControl("hiddenFieldId");
            //    if (hiddenField != null) ExcluiRegistro(Convert.ToInt32(hiddenField.Value));

            //}
        }

        protected void buttonCadastrarEntrada_OnClick(object sender, EventArgs e)
        {
            Response.Redirect("~/CadastroEntradaProduto.aspx");
        }

        protected void buttonCadastrarSaida_OnClick(object sender, EventArgs e)
        {
            Response.Redirect("~/CadastroSaidaProduto.aspx");
        }

        protected void gridView_OnSorted(object sender, EventArgs e)
        {
            
        }

        protected void gridView_OnPageIndexChanged(object sender, EventArgs e)
        {
            
        }

        protected void ddPageSize_SelectedIndexChanged(object sender, EventArgs e)
        {
            
        }
    }
}